<?php
class ControllerModuleBossHomecategory extends Controller {
    protected function index($setting) {
        static $module = 0;
       
       	$this->data['button_cart'] = $this->language->get('button_cart');
		$this->data['template'] = $this->config->get('config_template');
		
		//
		$this->load->model('catalog/category');
		$this->load->model('tool/image');
		
		$this->load->language('module/boss_homecategory');
		
       	$this->data['text_shop'] = $this->language->get('text_shop');

		$this->data['tabs'] = array();
	
		$tabs = $this->config->get('boss_homecategory_check');
		if (isset($tabs)) {
			$key = 0;
			foreach($tabs as $tab){
				if($key < $setting['limit'] ){ 
					$key ++; 
					$category = array();
					$category = $this->model_catalog_category->getCategory($tab);
					if ($category['image']) {
						$image = $this->model_tool_image->resize($category['image'], $setting['width'], $setting['height']);
					} else {
						$image = false;
					}

					$this->data['tabs'][] = array(
							'image'			 => $image,
							'name'	 		 =>	$category['name'],
							'href'			 =>  $this->url->link('product/category', 'path=' . $category['category_id'])
					);
				}
			}
		}
		
		$this->data['module'] = $module++; 
       
	    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/boss_homecategory.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/module/boss_homecategory.tpl';
        } else {
            $this->template = 'default/template/module/boss_homecategory.tpl';
        }

        $this->render();
    }
}

?>